﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JYH.Framework
{
    public  class YaohuaXK3190A9
    {
        private string _Hands = "024141303003"; //握手指令
        private string _RoughWeight = "024142303303"; //读取毛重指令
        private string _Tare = "024143303203"; //送皮重
        private string _NetWeight = "024144303503";//净重
        private string _CarNO = "024145303403";//车号
        private string _MaterialNO = "024146303703";//货号
        /// <summary>
        /// 称重机握手指令
        /// </summary>
        public string Hands
        {
            get
            {
                return _Hands;
            }
            set
            {
                _Hands = value;
            }
        }
        /// <summary>
        /// 读取毛重指令
        /// </summary>
        public string RoughWeight
        {
            get
            {
                return _RoughWeight;
            }
            set
            {
                _RoughWeight = value;
            }
        }
        /// <summary>
        /// 读取皮重指令
        /// </summary>
        public string Tare
        {
            get
            {
                return _Tare;
            }
            set
            {
                _Tare = value;
            }
        }
        /// <summary>
        /// 读取净重指令
        /// </summary>
        public string NetWeight
        {
            get
            {
                return _NetWeight;
            }
            set
            {
                _NetWeight = value;
            }
        }
        /// <summary>
        /// 读取车号指令
        /// </summary>
        public string CarNO
        {
            get
            {
                return _CarNO;
            }
            set
            {
                _CarNO = value;
            }
        }
        /// <summary>
        /// 读取货号指令
        /// </summary>
        public string MaterialNO
        {
            get
            {
                return _MaterialNO;
            }
            set
            {
                _MaterialNO = value;
            }
        }

        private string _ResultString;
        public string ResultString
        {
            get
            {
                return _ResultString;
            }
            set
            {
                _ResultString = value;
            }
        }
        public decimal ResultValue
        {
            get
            {
                
                string Res = ResultString.Replace(" ", "|");
                string[] ListRes = Res.Split('|');
                if (ListRes.Length < 14)
                {
                    return 0;
                }
                else
                {

                    decimal A4 = (Convert.ToInt32((ListRes[4].ToString())) - 30) * 1000M;
                    decimal A3 = (Convert.ToInt32((ListRes[5].ToString())) - 30) * 100M;
                    decimal A2 = (Convert.ToInt32((ListRes[6].ToString())) - 30) * 10M;
                    decimal A1 = (Convert.ToInt32((ListRes[7].ToString())) - 30) * 1M;
                    decimal B1= (Convert.ToInt32((ListRes[8].ToString())) - 30) *0.1M;
                    decimal B2 = (Convert.ToInt32((ListRes[9].ToString())) - 30) * 0.01M;
                    return A4 + A3 + A2 + A1 + B1 + B2;
                }


            }
          
        }
    }
}
